import React from "react";
import { Row, Col, Popover, Checkbox, Button } from "antd";
import { Link } from "react-router";

class NewsPage extends React.Component {
    render() {
        const newsList = this.props.data || [];

        return <div className={ "list " + this.props.className }>
                   { newsList.map((item, i) => <News key={ i } data={ item } />) }
               </div>;
    }
}

class News extends React.Component {
    
    render() {
        const {id, type, msg, status, time} = this.props.data;
        let title = "系统消息";
        if (type == "service")
            title = "售后消息";else if (type == "invite")
            title = "邀请消息";

        return <div className="l-row" data-type={ type }>
                   <div className="ct">
                       <div>
                           <span className="title">{ title }</span>
                           <span className="time">{ time }</span>
                       </div>
                       <div>
                           <span className="msg">{ msg }</span>
                           { status == 0 ? <Button type="primary" size={ "small" } className="mark">标记为已读</Button> : <Button disabled size={ "small" } className="mark">已读</Button> }
                       </div>
                   </div>
               </div>
    }
}

export { News };

export default NewsPage;